<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>

		<script type="text/javascript">
			//3.开发游戏有如下类，请尝试声明父类，下面所有类继承这个父类。

			//声明父类
			function Base(name, level) {
				this.name = name;
				this.level = level;
			}
			//人物类继承
			function F(){}
				F.prototype = Base.prototype;

			function Human(name, level, sex) {
				Base.call(this, name, level);
				this.sex = sex;
			}
			Human.prototype = new F();
			Human.prototype.constructor = Human;
			let human = new Human("张飞", 5, "男");
			console.log(human);

			//怪物类继承
			function Creep(name, level, exp) {
				Base.call(this, name, level);
				this.exp = exp;
			}
			Creep.prototype = new F();
			Creep.prototype.constructor = Creep;
			let creep =new Creep("蜘蛛",3,"女");
			console.log(creep);
			
			//道具类继承
			function Item(name,level,type){
				Base.call(this,name,level);
				this.type = type;
			}			
			Item.prototype = new F();
			Item.prototype.constructor = Item;
			let item = new Item("血包",2,"恢复类");
			console.log(item);
		</script>
	</body>
</html>
